package com.xgzit.xgzmall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @Author xgz
 * @Date 2021-04-24 14:07
 */

@Configuration
public class MyRedissonConfig {

    /**
    * 所有对 Redisson 的使用都是通过 RedissonClient 对象
    * @return org.redisson.api.RedissonClient
    */
    @Bean(destroyMethod = "shutdown")
    RedissonClient redisson() throws IOException {
        Config config = new Config();
        /*config.useClusterServers().addNodeAddress(
                "xgzit.com:7004", "127.0.0.1:7001"
        );*/
        // 如果是 https， 写成 rediss://xgzit.com:6379
        config.useSingleServer().setAddress("redis://xgzit.com:6379").setPassword("xgzredis");
        return Redisson.create(config);
    }
}
